package com.ourteam.workspace.api;

import org.apache.commons.lang3.StringUtils;

import com.ourteam.frame.web.AbstractSearchModel;
import com.ourteam.workspace.dao.WorkspaceResourceUIPageRelateDAOQueryBean;
import com.ourteam.workspace.domain.WorkspaceResourceUIPageRelateBean;

public class ResourceRelatedUIPageSearchModel extends AbstractSearchModel<WorkspaceResourceUIPageRelateDAOQueryBean> {

	private long workspaceResourceId;

	private long workspaceId;
	
	private Long domainId;
	
	private String pageName;
	
	private String pageCode;

	@Override
	public String getMappedDAOField(String aProperty) {
		return WorkspaceResourceUIPageRelateBean.getMappedDAOField(aProperty);
	}

	@Override
	protected void doBuildQueryBean(WorkspaceResourceUIPageRelateDAOQueryBean queryBean) throws Exception {
		WorkspaceResourceUIPageRelateDAOQueryBean.Criteria criteria = queryBean.createCriteria();
		if (workspaceResourceId != 0) {
			criteria.andWorkspaceResourceIdEqualTo(workspaceResourceId);
		}
		if (workspaceId != 0) {
			criteria.andWorkspaceIdEqualTo(workspaceId);
		}
		
		if(this.domainId != null && this.domainId.longValue() != 0) {
			criteria.andUiDomainIdEqualTo(domainId);
		}
		
		if(StringUtils.isNoneBlank(this.pageCode)) {
			criteria.andPageCodeLike(pageCode);
		}
		
		if(StringUtils.isNoneBlank(this.pageName)) {
			criteria.andPageNameLike(pageName);
		}

	}

	public long getWorkspaceResourceId() {
		return workspaceResourceId;
	}

	public void setWorkspaceResourceId(long workspaceResourceId) {
		this.workspaceResourceId = workspaceResourceId;
	}

	public long getWorkspaceId() {
		return workspaceId;
	}

	public void setWorkspaceId(long workspaceId) {
		this.workspaceId = workspaceId;
	}

	public Long getDomainId() {
		return domainId;
	}

	public void setDomainId(Long domainId) {
		this.domainId = domainId;
	}

	public String getPageName() {
		return pageName;
	}

	public void setPageName(String pageName) {
		this.pageName = pageName;
	}

	public String getPageCode() {
		return pageCode;
	}

	public void setPageCode(String pageCode) {
		this.pageCode = pageCode;
	}

	
}
